
import React from 'react';
import { MicroAppContext } from '../context/MicroAppContext';
import useMatcher from '../hooks/useMatcher'

const Matcher = ({ children }: any) => {
  const { basename } = React.useContext(MicroAppContext)
  const genRules = () => {
    let rules = {}
    React.Children.forEach(children, c => {
      
      rules[basename + c.props.path] = c.props
    })
    return rules
  }
  const { element } = useMatcher({ rules: genRules() })

  return element as unknown as JSX.Element
}
export default Matcher